<!DOCTYPE html>
<html lang="zh_CN">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div id="app">
    <p>vue2的基本使用</p>

    <ul>
        <li v-for="ele in userInfo">{{ ele }}</li>
    </ul>

    <button @click="changeHandler">操作数据</button>

</div>
</body>
<script src="js/vue3.js"></script>

<script type="text/javascript">

    const {createApp, reactive} = Vue;

    const vm = createApp({
        setup() {
            const userInfo = reactive({
                    id: 12,
                    name: 'andy',
                    age: 23,
                    work: {
                        name: 'pm',
                        skills: ['vue', 'react'],
                    }
                }
            )

            console.log(userInfo);

            const changeHandler = () => {
                console.log('changeHandler');
                // userInfo.age += 1;

                // userInfo.nickName = 'mark';
                // this.$set(this.userInfo, 'nickName', 'mark');

                // delete userInfo.name;
                // this.$delete(this.userInfo, 'name');

                userInfo.work.skills[0] = 'Vue';

            }

            return {
                userInfo,
                changeHandler,
            }
        }
    })

    vm.mount('#app');


</script>

</html>
